/** * @fn void palette_t::update_adjusted_color(UINT32 group, UINT32 index) * * @brief ------------------------------------------------- * update_adjusted_color - update a color index by group and index pair * -------------------------------------------------. * * @param group The group. * @param index Zero-based index of the. */ void update_adjusted_color(uint32_t group, uint32_t index) { // compute the adjusted value rgb_t adjusted = adjust_palette_entry(m_entry_color[index], m_group_bright[group] + m_brightness, m_group_contrast[group] * m_entry_contrast[index] * m_contrast, m_gamma_map); // if not different, ignore uint32_t finalindex = group * m_numcolors + index; if (m_adjusted_color[finalindex] == adjusted) { return; } // otherwise, modify the adjusted color array m_adjusted_color[finalindex] = adjusted; m_adjusted_rgb15[finalindex] = adjusted.as_rgb15(); // mark dirty in all clients for (palette_client client = m_client_list; client != null; client = client.next()) { client.mark_dirty(finalindex); } }
// construction/destruction //------------------------------------------------- // palette_t - constructor //------------------------------------------------- palette_t(uint32_t numcolors, uint32_t numgroups = 1) { m_refcount = 1; m_numcolors = numcolors; m_numgroups = numgroups; m_brightness = 0.0f; m_contrast = 1.0f; m_gamma = 1.0f; m_entry_color = new std.vector <rgb_t>((int)numcolors); m_entry_contrast = new std.vector <float>((int)numcolors); m_adjusted_color = new std.vector <rgb_t>((int)(numcolors * numgroups + 2)); m_adjusted_rgb15 = new std.vector <rgb15_t>((int)(numcolors * numgroups + 2)); m_group_bright = new std.vector <float>((int)numgroups); m_group_contrast = new std.vector <float>((int)numgroups); m_client_list = null; // initialize gamma map for (uint32_t index = 0; index < 256; index++) { m_gamma_map[index] = (uint8_t)index; } // initialize the per-entry data for (uint32_t index = 0; index < numcolors; index++) { m_entry_color[index] = rgb_t.black(); m_entry_contrast[index] = 1.0f; } // initialize the per-group data for (uint32_t index = 0; index < numgroups; index++) { m_group_bright[index] = 0.0f; m_group_contrast[index] = 1.0f; } // initialize the expanded data for (uint32_t index = 0; index < numcolors * numgroups; index++) { m_adjusted_color[index] = rgb_t.black(); m_adjusted_rgb15[index] = rgb_t.black().as_rgb15(); } // add black and white as the last two colors m_adjusted_color[numcolors * numgroups + 0] = rgb_t.black(); m_adjusted_rgb15[numcolors * numgroups + 0] = rgb_t.black().as_rgb15(); m_adjusted_color[numcolors * numgroups + 1] = rgb_t.white(); m_adjusted_rgb15[numcolors * numgroups + 1] = rgb_t.white().as_rgb15(); }
dirty_state [] m_dirty = new dirty_state[2]; // two dirty states // construction/destruction //------------------------------------------------- // palette_client - constructor //------------------------------------------------- public palette_client(palette_t palette) { m_palette = palette; m_next = null; m_liveIdx = 0; // m_live(&m_dirty[0]), m_previousIdx = 1; // m_previous(&m_dirty[1]) // add a reference to the palette palette.ref_(); // resize the dirty lists uint32_t total_colors = (uint32_t)(palette.num_colors() * palette.num_groups()); m_dirty[0] = new dirty_state(); m_dirty[1] = new dirty_state(); m_dirty[0].resize(total_colors); m_dirty[1].resize(total_colors); // now add us to the list of clients m_next = palette.m_client_list; palette.m_client_list = this; }